package com.deyuanyun.pic.insp.controller.statistics;

import com.deyuanyun.pic.common.util.RequestUtil;
import com.deyuanyun.pic.common.util.ResponseUtil;
import com.deyuanyun.pic.settings.controller.AbstractBaseController;
import com.deyuanyun.pic.insp.service.statistics.InspSteelPileService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

/**
 * 
 * 内检测 统计 壁厚统计
 * @author    scalpel.Wang
 * @version   2015年10月17日
 * @see         // 引用的类
 * Method List:                       // 主要函数及其功能    
 *         1.toPage   ---------------- 去主页
 *         2.search   ---------------- 搜索数据
 * History:                           // 历史修改记录
 */
@Controller
@RequestMapping("/insp/statistics/wall")
public class InspSteelPileController extends AbstractBaseController {

	@Resource
	InspSteelPileService inspSteelPileService;
	
	@RequestMapping("/page.html")
	public ModelAndView toPage(){
		ModelAndView mav=new ModelAndView();

		//查询管道名称 
		List lineList=lineService.getLine();
		
		mav.addObject("lineList", lineList);
		mav.setViewName("/insp/statistics/wall");
		return mav;
		
	}
	
	@RequestMapping("/search")
	public void search(
					   HttpServletRequest request,
			           HttpServletResponse response){
		
		StringBuffer resultJson=new StringBuffer();
		resultJson.append("{");
		HashMap param= RequestUtil.parseRequestParamToHashMap(request);
		List data=inspSteelPileService.findStatisticsgirtList(param);
		resultJson.append("\"list\":").append(ResponseUtil.getJson(data)).append(",");
		data=inspSteelPileService.findStatisticsBar(param);
		resultJson.append("\"pie\":").append(ResponseUtil.getJson(data)).append(",");
		data=inspSteelPileService.findStatisticsLine(param);
		resultJson.append("\"line\":").append(ResponseUtil.getJson(data));
		resultJson.append("}");
		ResponseUtil.printl(response, resultJson.toString(), "JSON");
	}
}
